const state = {
  tag: new Array(),
  tagSelectModel: ''
}
const mutations = {
  SET_TAG: (state, data) => {
    try {
      for (let i = 0; i < state.tag.length; i++) {
        if (state.tag[i].id == data.id) {
            state.tag.splice(i, 1)
        }
      }
    } catch (e) {
    }
    state.tag.push(data)
  },
  SET_TAG_SELECT_MODEL: (state, data) => {
      state.tagSelectModel=data
  },
  CLEAN_TAG: (state) => {
    state.tag = new Array()
    state.tagSelectModel=''
  },
  CLEAN_TAG_DATA: (state) => {
    state.tag = new Array()
  }
}

const actions = {
  // 设置
  setTag({ commit }, data) {
    commit('SET_TAG', data)
  },
  // 设置选择模式
  setTagSelectModel({ commit }, data) {
    commit('SET_TAG_SELECT_MODEL', data)
  },
  // 清空-全部清空
  cleanTag({ commit }) {
    commit('CLEAN_TAG')
  },

  cleanTagData({ commit }) {
    commit('CLEAN_TAG_DATA')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

